package net.xdclass.online_xdclass.controller;

import net.xdclass.online_xdclass.model.entity.Video;
import net.xdclass.online_xdclass.model.entity.VideoBanner;
import net.xdclass.online_xdclass.service.VideoService;
import net.xdclass.online_xdclass.utils.JsonData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("api/v1/pub/video")
public class VideoController {
    @Autowired
    private VideoService videoService;

    /**
     * 视频查询
     * @return
     */
    @RequestMapping("list")
    public JsonData listVideo(){
        List<Video> videos=videoService.listVideo();
        System.out.println("1----------------------------");
        return JsonData.buildSuccess(videos);

    }

    /**
     * 轮播图查询
     * @return
     */
    @GetMapping("list_banner")
    public JsonData listVideoBanner(){
        List<VideoBanner> videoBanners=videoService.listVideoBanner();

        System.out.println("2----------------------------");
        return JsonData.buildSuccess(videoBanners);
    }

    /**
     * 视频章节查询
     * @param videoId
     * @return
     */
    @GetMapping("find_detail_by_id")
    //@RequestParam(value = "video_id",required = true  ture:必须传值
    public JsonData findDetailById(@RequestParam(value = "video_id",required = true) int videoId){

    Video video= videoService.findDetailById(videoId);
        return JsonData.buildSuccess(video);
    }
}
